/*
 * @Author: earl 
 * @Date: 2018-12-10 15:59:07 
 * @Last Modified by: earl
 * @Last Modified time: 2018-12-10 16:44:57
 * @Describe:  获取get参数
 */
const Koa = require('Koa')
const app = new Koa()

app.use(async (ctx)=>{
  let url = ctx.url
  // 从上下文中的request对象中获取
  let request = ctx.request
  let req_query = request.query
  let req_querystring = request.querystring
  
  // 从上下文中直接获取
  let ctx_query = ctx.query
  let ctx_querystring = ctx.querystring

  ctx.body = {
    url,
    req_query,
    req_querystring,
    ctx_query,
    ctx_querystring
  }
})

app.listen(3000, ()=>{
  console.log('[demo] request get is starting at port 3000')
})